<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateYFeedbacksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('y_feedbacks')) {
            Schema::create('y_feedbacks', function (Blueprint $table) {
                $table->engine = 'MyISAM';
                $table->increments('feedback_id');
                $table->integer('feedback_from_user_id')->default(0)->comment('消息发送人id');
                $table->integer('feedback_to_user_id')->default(0)->comment('消息接收人id');
                $table->text('feedback_content')->comment('消息内容');
                $table->string('feedback_thumbnail',60)->default('')->comment('图片名称');
                $table->boolean('feedback_status')->default(1)->comment('状态 2已读，1未读，0删除');
                $table->timestamps();

                //索引
                $table->index(['feedback_from_id','feedback_status']);
                $table->index(['feedback_to_id','feedback_status']);
            });
        };
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('y_feedbacks');
    }
}
